<?php

namespace app\models;

// 在bootstrap.php中添加ActiveRecord的模拟实现
namespace yii\db {
    class ActiveRecord {
        public static function tableName() {
            return '';
        }
        
        public function rules() {
            return [];
        }
        
        public function attributeLabels() {
            return [];
        }
    }
}

namespace app\models;

use yii\db\ActiveRecord;

class User extends ActiveRecord {
    // 指定表名
    public static function tableName() {
        return 'user';
    }
    
    // 验证规则
    public function rules() {
        return [
            [['username', 'email', 'password'], 'required'],
            ['email', 'email'],
            ['username', 'string', 'min' => 3, 'max' => 50],
        ];
    }
    
    // 属性标签
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'username' => '用户名',
            'email' => '邮箱',
            'password' => '密码',
        ];
    }
}
?>